package com.xomily.devops.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xomily.common.annotation.Log;
import com.xomily.common.core.controller.BaseController;
import com.xomily.common.core.domain.AjaxResult;
import com.xomily.common.enums.BusinessType;
import com.xomily.devops.domain.DevProgramLog;
import com.xomily.devops.service.IDevProgramLogService;
import com.xomily.common.utils.poi.ExcelUtil;
import com.xomily.common.core.page.TableDataInfo;

/**
 * 进程日志Controller
 * 
 * @author xomily
 * @date 2021-11-29
 */
@RestController
@RequestMapping("/devops/programLog")
public class DevProgramLogController extends BaseController
{
    @Autowired
    private IDevProgramLogService devProgramLogService;

    /**
     * 查询进程日志列表
     */
    @PreAuthorize("@ss.hasPermi('devops:programLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(DevProgramLog devProgramLog)
    {
        startPage();
        List<DevProgramLog> list = devProgramLogService.selectDevProgramLogList(devProgramLog);
        return getDataTable(list);
    }

    /**
     * 导出进程日志列表
     */
    @PreAuthorize("@ss.hasPermi('devops:programLog:export')")
    @Log(title = "进程日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DevProgramLog devProgramLog)
    {
        List<DevProgramLog> list = devProgramLogService.selectDevProgramLogList(devProgramLog);
        ExcelUtil<DevProgramLog> util = new ExcelUtil<DevProgramLog>(DevProgramLog.class);
        return util.exportExcel(list, "进程日志数据");
    }

    /**
     * 获取进程日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('devops:programLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(devProgramLogService.selectDevProgramLogById(id));
    }

    /**
     * 新增进程日志
     */
    @PreAuthorize("@ss.hasPermi('devops:programLog:add')")
    @Log(title = "进程日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DevProgramLog devProgramLog)
    {
        return toAjax(devProgramLogService.insertDevProgramLog(devProgramLog));
    }

    /**
     * 修改进程日志
     */
    @PreAuthorize("@ss.hasPermi('devops:programLog:edit')")
    @Log(title = "进程日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DevProgramLog devProgramLog)
    {
        return toAjax(devProgramLogService.updateDevProgramLog(devProgramLog));
    }

    /**
     * 删除进程日志
     */
    @PreAuthorize("@ss.hasPermi('devops:programLog:remove')")
    @Log(title = "进程日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(devProgramLogService.deleteDevProgramLogByIds(ids));
    }
}
